<?php

namespace App\Http\Controllers;
use DB;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class XXController extends BaseController
{
    //添加数据
   public function add(){
       $row=['title'=>'haha','name'=>'lcx'];
       $data=array(
           array('title'=>'abc','name'=>'箫洒哥'),
           array('title'=>'DNF','name'=>'囧'),
       );
       //var_dump( DB::table('goods')->insert($data));
       //var_dump( DB::table('goods')->insertGetId($data));
   }
    //修改数据
    public function up(){
       // var_dump(DB::table('goods')->where('id',1)->update(['name'=>'李四','title'=>'qq']));
       // var_dump(DB::table('goods')->where('id','5')->increment('id','5'));   //increment加(自增) 第二个参数是步长
          var_dump(DB::table('goods')->where('id','10')->decrement('id','6'));  //decrement减(自减) 第二个参数是步长
    }
    //删除数据
    public function del(){
        var_dump(DB::table('goods')->where('id',4)->delete());
    }
    //查询数据
    public function show(){
        var_dump(DB::table('goods')->get());
        //var_dump(DB::table('goods')->where('id','2')->get());
        //var_dump(DB::table('goods')->select('id','name','title')->where('id','>','0')->get());
        //var_dump(DB::table('goods')->where('id','3')->first());
    }
}